function sendData(){
	var formData = $('#loginForm').serialize();
	$.ajax( {url: "login.php",
			type: "POST",
			data:  formData,
			contentType: "application/x-www-form-urlencoded; charset=UTF-8",
			success: function(data, textStatus, jqXHR)
			{	
				$("#invisDiv").html( data );
				if(document.getElementById('loginErrorOccured')){
					openNewUnit(document.getElementById('loginErrorOccured').innerHTML, 'error');
				}else{
					$("#toppanel").html( data );
					// Expand Panel
					$("#open").click(function(){
						$("div#panel").slideDown("slow");
					
					});	
					// Collapse Panel
					$("#close").click(function(){
						$("div#panel").slideUp("slow");	
					});		
					// Switch buttons from "Log In | Register" to "Close Panel" on click
					$("#toggle a").click(function () {
						$("#toggle a").toggle();
					});
							
					$("#open").click();
				}
			}});
}


function forgetPass(){
	var formData = $('#loginForm').serialize();
	$.ajax( {url: "forget_pass.php",
			type: "POST",
			data:  formData,
			contentType: "application/x-www-form-urlencoded; charset=UTF-8",
			success: function(data, textStatus, jqXHR)
			{	
				if(data.trim()==''){
					openNewUnit('Şifre değiştirme işleminiz gerçekleştirilmiştir ve geçerli şifreniz e-mail adresinize postalanmıştır.<br/>', 'success');
				}else{
					openNewUnit(data, 'error');
				}
			}});
}

$('#password').keyup(function(event){
	if(event.keyCode == 13){
		sendData();
	}
});

$('#username').keyup(function(event){
	if(event.keyCode == 13){
		$('#password').focus();
	}
});